package com.dahe.ysxt.vector.audit.control;

import com.alibaba.fastjson.JSON;
import com.dahe.ysxt.vector.audit.entity.AuditResult;
import com.dahe.ysxt.vector.audit.entity.LikeAuditResult;
import com.dahe.ysxt.vector.audit.service.AuditService;
import com.dahe.ysxt.vector.common.ResponseBean;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ysxt/audit")
public class AuditControl {
    @Autowired
    private AuditService auditService;

    /**
     * 从人工审核李书记记录表中找到匹配正词和错词，相似性查询匹配度最高的记录
     * @param httpServletRequest
     * @param id  指定过滤掉的id
     * @param errorWords  错词
     * @param correctWords 正词
     * @param conText 进行相似性查询的正文
     * @return
     */
    @RequestMapping(value = "queryByEmbedding")
    @ResponseBody
    public ResponseBean<LikeAuditResult> queryByEmbedding(HttpServletRequest httpServletRequest, @RequestParam Long id, @RequestParam String errorWords, @RequestParam String correctWords, @RequestParam String conText) {
        ResponseBean<LikeAuditResult> responseBean = new ResponseBean<LikeAuditResult>();
        LikeAuditResult likeAuditResult = auditService.queryByEmbedding(id, errorWords, correctWords, conText);
        responseBean.setData(likeAuditResult);
        return responseBean;
    }

    /**
     * 遍历人工审很合记录表，找到每条记录相似度匹配最高的对应记录
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = "batchSetEmbedding")
    @ResponseBody
    public ResponseBean<Void> batchSetEmbedding(HttpServletRequest httpServletRequest) {
        ResponseBean<Void> responseBean = new ResponseBean<Void>();
        auditService.batchSetEmbedding();
        return responseBean;
    }

    @RequestMapping(value = "queryDbAuditResult")
    @ResponseBody
    public ResponseBean<Void> queryDbAuditResult(HttpServletRequest httpServletRequest) {
        ResponseBean<Void> responseBean = new ResponseBean<Void>();
//        auditService.batchAuditDB();
        return responseBean;
    }


    /**
     * 创建Database和collection
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = "createCollection")
    @ResponseBody
    public ResponseBean<Void> createCollection(HttpServletRequest httpServletRequest) {
        ResponseBean<Void> responseBean = new ResponseBean<Void>();
//        auditService.createCollection();
        return responseBean;
    }
}
